Follow the default collation of Rails rather than MySQL.

`utf8*_unicode_ci` is known to be problematic in some languages like
Japanese, but hopefully it wouldn't do harm in practice in our case.

Akinori MUSHA 10 years ago
parent
commit
393e3c4ddc
2 changed files with 5 additions and 5 deletions
  1. 4 4
      db/migrate/20140813110107_set_charset_for_mysql.rb
  2. 1 1
      db/schema.rb

+ 4 - 4
db/migrate/20140813110107_set_charset_for_mysql.rb

@@ -40,10 +40,10 @@ class SetCharsetForMysql < ActiveRecord::Migration
40 40
 
41 41
             case type
42 42
             when :string, :text
43
-              options.update(charset: 'utf8', collation: 'utf8_general_ci')
43
+              options.update(charset: 'utf8', collation: 'utf8_unicode_ci')
44 44
               case name
45 45
               when 'username'
46
-                options.update(limit: 767 / 4, charset: 'utf8mb4', collation: 'utf8mb4_general_ci')
46
+                options.update(limit: 767 / 4, charset: 'utf8mb4', collation: 'utf8mb4_unicode_ci')
47 47
               when 'message', 'options', 'name', 'memory',
48 48
                    'handler', 'last_error', 'payload', 'description'
49 49
                 options.update(charset: 'utf8mb4', collation: 'utf8mb4_bin')
@@ -60,10 +60,10 @@ class SetCharsetForMysql < ActiveRecord::Migration
60 60
             change_column table_name, name, type, options
61 61
           }
62 62
 
63
-          execute 'ALTER TABLE %s CHARACTER SET utf8 COLLATE utf8_general_ci' % table_name
63
+          execute 'ALTER TABLE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % table_name
64 64
         }
65 65
 
66
-        execute 'ALTER DATABASE %s CHARACTER SET utf8 COLLATE utf8_general_ci' % conn.current_database
66
+        execute 'ALTER DATABASE %s CHARACTER SET utf8 COLLATE utf8_unicode_ci' % conn.current_database
67 67
       end
68 68
 
69 69
       dir.down do

+ 1 - 1
db/schema.rb

@@ -164,7 +164,7 @@ ActiveRecord::Schema.define(version: 20140813110107) do
164 164
     t.integer  "failed_attempts",                    default: 0
165 165
     t.string   "unlock_token"
166 166
     t.datetime "locked_at"
167
-    t.string   "username",               limit: 191,                 null: false, charset: "utf8mb4", collation: "utf8mb4_general_ci"
167
+    t.string   "username",               limit: 191,                 null: false, charset: "utf8mb4", collation: "utf8mb4_unicode_ci"
168 168
     t.string   "invitation_code",                                    null: false,                     collation: "utf8_bin"
169 169
     t.integer  "scenario_count",                     default: 0,     null: false
170 170
   end